package hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.util.Bytes;


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class HbaseUtilD  {


    public String Delete(String rowkey) throws IOException {
        Configuration conf= HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","192.168.116.11");
        Connection connection = ConnectionFactory.createConnection(conf);
        Table table = connection.getTable(TableName.valueOf("goodsmessage"));
        List list = new ArrayList();
        Delete delete = null;

        try {
            //创建删除对象
            delete = new Delete(Bytes.toBytes(rowkey));
        }catch (Exception e){
            e.printStackTrace();
        }

        list.add(delete);
        //执行删除操作
        table.delete(list);

//        org.apache.hadoop.hbase.client.Delete delete=new org.apache.hadoop.hbase.client.Delete(dln.getBytes());
//        table.delete(delete);

        return "删除成功";

    }

}
